#!/usr/bin/env bash

set -eu

if [[ "${BUILDKITE_STEP_KEY}" == "index" ]]; then
  echo "--- :tada: Configuring git user"

  git config user.name "Authelia[bot]"
  git config user.email "autheliabot@users.noreply.github.com"
fi

if [[ "${BUILDKITE_STEP_KEY}" == "upload" ]] || [[ "${BUILDKITE_STEP_KEY}" == "index" ]]; then
  echo "--- :arrow_down: Downloading artifacts"

  rm -rf .cr-release-packages .cr-index
  mkdir -p .cr-release-packages .cr-index

  buildkite-agent artifact download .cr-release-packages/* .cr-release-packages
fi